#ifndef OBJECT_NODE_H_
#define OBJECT_NODE_H_

#include "SceneGraphNode.h"

class ObjectNode : public SceneGraphNode
{
private:
    static int INDEX_BEGIN_NEXT;
    static int INDEX_MIDDLE_NEXT;
    static int INDEX_END_NEXT;
public:
    static const int DRAW_FIRST = 0;
    static const int DRAW_MIDDLE = 1;
    static const int DRAW_LAST = 2;
    static const int TYPE = 1;
private:
    int drawIndex;
    void *drawData;
    bool visible;
public:
    ObjectNode(SceneGraphNode *parent = NULL, int drawLocation = DRAW_MIDDLE, void *drawData = NULL, int drawIndex = -1, bool ownsChildren = false)
    :SceneGraphNode(parent, ownsChildren)
    {
        if(drawIndex == -1){
            switch (drawLocation){
                case DRAW_FIRST:
                    drawIndex = INDEX_BEGIN_NEXT++;
                    break;
                case DRAW_MIDDLE:
                    drawIndex = INDEX_MIDDLE_NEXT++;
                    break;
                case DRAW_LAST:
                    drawIndex = INDEX_END_NEXT++;
                    break;
            }
        }

        this->drawIndex = drawIndex;
        this->drawData = drawData;
        this->type |= ObjectNode::TYPE;
        visible = true;
    }

    virtual ~ObjectNode()
    {
    }

    inline void setDrawData(void *drawData)
    {
        this->drawData = drawData;
    }

    inline void *getDrawData()
    {
        return drawData;
    }

    inline void setDrawIndex(int drawIndex)
    {
        this->drawIndex = drawIndex;
    }

    inline int getDrawIndex()
    {
        return drawIndex;
    }

    bool getVisible() const
    {
        return visible;
    }

    void setVisible(bool visible)
    {
        this->visible = visible;
    }

    virtual void update()
    {
    }
};

#endif
